package TP;

public class PurseTest {

	static void test_1_ok() {
		byte[] my_pin = new byte[] { 0, 1, 2, 3 };
		int my_balance = 0;
		int my_max_balance = 40;

		Purse purse = new Purse(my_max_balance, my_balance, my_pin);
		try {
			purse.deposit(15);
			purse.debit(12);
		} catch (PurseException e) {
			assert false;
		}
	}

	static void test_1_fail() {
		byte[] my_pin = new byte[] { 0, 1, 2, 3 };
		int my_balance = 0;
		int my_max_balance = 40;

		Purse purse = new Purse(my_max_balance, my_balance, my_pin);
		try {
			purse.deposit(15);
			purse.debit(12);
			assert false;
		} catch (PurseException e) {

		}
	}

	static void test_2_ok() {
		byte[] my_pin = new byte[] { 0, 1, 2, 3 };
		int my_balance = 0;
		int my_max_balance = 40;

		Purse purse = new Purse(my_max_balance, my_balance, my_pin);
		try {
			purse.deposit(10);
			purse.debit(12);
			assert false;
		} catch (PurseException e) {

		}
	}

	static void test_2_fail() {
		byte[] my_pin = new byte[] { 0, 1, 2, 3 };
		int my_balance = 0;
		int my_max_balance = 40;

		Purse purse = new Purse(my_max_balance, my_balance, my_pin);
		try {
			purse.deposit(10);
			purse.debit(12);
		} catch (PurseException e) {
			assert false;
		}
	}

	static void test_3_ok() {
		byte[] my_pin = new byte[] { 0, 1, 2, 3 };
		int my_balance = 0;
		int my_max_balance = 40;

		Purse purse = new Purse(my_max_balance, my_balance, my_pin);

		byte[] other_pin = new byte[] { 0, 1, 7, 3 };

		if (purse.checkPin(other_pin)) {
			assert false;
		}
	}

	static void test_3_fail() {
		byte[] my_pin = new byte[] { 0, 1, 2, 3 };
		int my_balance = 0;
		int my_max_balance = 40;

		Purse purse = new Purse(my_max_balance, my_balance, my_pin);

		byte[] other_pin = new byte[] { 0, 1, 7, 3 };

		if (!purse.checkPin(other_pin)) {
			assert false;
		}
	}

	static void test_4_ok() {
		byte[] my_pin = new byte[] { 0, 1, 2, 3 };
		int my_balance = 0;
		int my_max_balance = 40;

		Purse purse = new Purse(my_max_balance, my_balance, my_pin);
		
		try {
			purse.deposit(my_max_balance * 2);
			assert false;
		} catch (PurseException e) {
		}

	}
	
	static void test_4_fail() {
		byte[] my_pin = new byte[] { 0, 1, 2, 3 };
		int my_balance = 0;
		int my_max_balance = 40;

		Purse purse = new Purse(my_max_balance, my_balance, my_pin);
		
		try {
			purse.deposit(my_max_balance * 2);
		} catch (PurseException e) {
			assert false;
		}

	}
	

}
